package a.autocode.app.maker;

import java.io.IOException;
import java.io.InputStream;

import jplat.tools.string.XLog;

public class AppServiceMain
{
	/************************
	 * 为了防止错误覆盖文件,
	 * 请先确认是否需要覆盖已存在文件. 
	 * true-覆盖 false-不覆盖.
	 ****************************/
	public static boolean OVERRIDE;
	
	static {
		OVERRIDE = true;
	}

	public static void main(String args[])
	{
/*		AppServiceMain main = new AppServiceMain();
		main.test();*/
		//配置文件读取和文件字符集
		String confpath = "/Users/macbook/Documents/workspace/dolphine/src/a/autocode/app/maker/app_autocode.conf";
		String charset = "utf-8";
		
		try
		{
			AppServiceMaker maker = new AppServiceMaker(confpath,"utf-8");
			
			//为了防止错误覆盖文件，请先确认是否需要覆盖已存在文件. true-覆盖 false-不覆盖.
			maker.override = OVERRIDE;
			
			maker.doParseConfFile();
			maker.doAutoCode();
			maker.doPortFileBackup();
//			XLog.log(JsonCoder.toJsonString(maker.config));
		}
		catch (IOException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	private void test()
	{
		String file = "classpath:a\\autocode\\app\\maker\\app_autocode.conf";
		InputStream ins = getClass().getResourceAsStream(file);
		XLog.log("url-%s", file.substring("classpath:".length()));
	}
}
